home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13375 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: lrz-muenchen.de!news
  2. From: ua302aa@lrz-muenchen.de ()
  3. Newsgroups: comp.lang.c
  4. Subject: Re: [QE] : file open problem
  5. Date: 7 Apr 1996 18:43:22 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4k92ca$sgj@sparcserver.lrz-muenchen.de>
  9. References: <4k8mja$ddn@news.kreonet.re.kr>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. Parao@kyebek.kjist.ac.kr (Don Kim) writes:
  13.  
  14. >Hello, there
  15.  
  16. >I have a problem with file opening.
  17. >In my code,
  18.  
  19. >    saveTextToFile ( char *text, char *filename)    {
  20. >    FILE *file;
  21.  
  22. >    if ( ( file = fopen (filename, "w") = = NULL ) 
  23.  
  24. Parenteses do not match! This cannot be the actual code, or it would
  25. not even compile, much less do what you describe. 
  26.  
  27. >        cout << "Cannot open file" << endl;
  28.  
  29. If you post to comp.lang.c, how about "fputs("Cannot open file\n", stderr);"?
  30.  
  31. >    else    {
  32. >        (void) fprintf (file, "%s\n", text);
  33. >        (void) fclose(file);
  34. >    }
  35. >   }
  36.  
  37. >   :
  38. >   :
  39.  
  40. >   char *_type = "part";    
  41. >   saveTextToFile ( _type, _type );
  42.  
  43. >Is anything wrong in my source code ? My program always displays "Cannot 
  44. >open file"....
  45.  
  46. Have you considered the possibility that you cannot open the file for
  47. reasons specific to your file system? There could be a directory with
  48. the name "part", or "part" could be a write protected file.
  49.  
  50. Kurt
  51. --
  52. | Kurt Watzka                             Phone : +49-89-2180-6254
  53. | watzka@stat.uni-muenchen.de
  54.